
using UnityEngine.UI;
using UnityEngine;
using System.Runtime.InteropServices.WindowsRuntime;
//using StarkMini;

public class AnswerPanel : MonoBehaviour
{
    public GameObject content;

    GameObject answerImgPrefab;

    private void Awake()
    {
        answerImgPrefab = Resources.Load<GameObject>("AnswerImage");
    }

    public void Show(int lvl)
    {
        for(int i=0; i< content.transform.childCount; i++)
        {
            content.transform.GetChild(i).gameObject.SetActive(false);
        }

        ImageURLs imageUR = Resources.Load<ImageURLs>("Level" + lvl);

        Image[] images = new Image[imageUR.levelURLs.Length];

        for (int i = 0; i < images.Length; i++)
        {
            GameObject answerImgObj = Instantiate(answerImgPrefab);
            answerImgObj.transform.SetParent(content.transform);
            answerImgObj.transform.localScale = Vector3.one;
            images[i] = answerImgObj.GetComponent<Image>();
        }

        WebImageReader.instance.LoadImages(imageUR, images, null);
    }

    private void OnDisable()
    {
        WebImageReader.instance?.StopLoadImag();
    }

    public void Close()
    {
        gameObject.SetActive(false);
    }
}
